package com.heima.Work;

/*
 * 同时开启两个线程，共同输出1-100之间的所有数字，并且将输出奇数的线程名称打印出来
 */
public class Work3 implements Runnable{
    private static int number =100;
    @Override
    public void run() {
        while (true) {
            synchronized (this){
                if (number <= 0) {
                    break;
                }
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                number--;
                if(number%2==1){
                    System.out.println("奇数："+Thread.currentThread().getName()+"---"+number);
                }
            }
        }
        }

        }



